<!DOCTYPE>
<html >
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>岗位首页</title>
    <link rel="stylesheet" href="__CSS__/layui.css"  media="all">
    <link rel="stylesheet" href="__CSS__/platform.css"  media="all">
    <script type="text/javascript" src="__UI__/layui.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/jquery.js"></script>
</head>
<style>
    .layui-colla-title,.layui-colla-icon,.laydate-set-ym{font-size: 18px;font-family:"Microsoft YaHei"}
    .layui-laydate{width: 100%}
    .layui-laydate .layui-laydate-main{width: 100%}
    .layui-laydate .layui-laydate-main .layui-laydate-content table{width: 100%}
</style>
<body>
<div class="index-top">
    <div class="index-top-logo fl">
        <a class="logo" href="{$official}"><img src="__IMG__/platform/logo.png"></a>
        <span>欢迎使用小马出行后台<small>|</small>岗位首页</span>
    </div>
    <div class="index-top-reture fr">
        <a href="{$index}"><img src="__IMG__/platform/jiantou.png">管理后台</a>
    </div>
    <div class="cl"></div>
</div>

<h1 class="tongji-bt">信息统计</h1>
<div class="index-left-cont">
    <div class="index-tongji">
        <div class="jine-box">
            <div class="ri-jine">
                <p>日合计总金额/元</p>
                <span>{$day}</span>
            </div>
            <div class="yue-jine">
                <p>月合计总金额/元</p>
                <span>{$month}</span>
            </div>
        </div>
    </div>
    <div class="tongji-title">
        <span></span>地区日合计金额/元
    </div>

    <div class="layui-collapse">
        <php>$k = $j = 0;</php>
        <volist name="region" id="p">
            <div class="layui-colla-item">
                <h2 class="layui-colla-title">{$p['name']}</h2>
                <php>unset($p['name']);$pc = $k == 0 ? 'layui-show' :'';$k++;$pid = $key;</php>
                <div class="layui-colla-content {$pc}">
                    <div class="layui-collapse sideMenu" lay-filter="region">
                        <volist name="p" id="c">
                            <div class="layui-colla-item">
                                <php>$cc = $j == 0 ? 'layui-show' :'';$act = $j == 0 ? 'yes' :'no';</php>
                                <h2 class="layui-colla-title" data-pid="{$pid}" data-value="{$key}" data-act="{$act}">{$c['name']}</h2>
                                <php>unset($c['name']);$j++;</php>
                                <ul class="layui-colla-content {$cc}" id="sta_{$pid}_{$key}">
                                    <eq name="j" value="1">
                                        <li class="title">
                                            <i class="layui-icon refresh layui-anim" onclick="refresh(this)"
                                               style="color: #1E9FFF;cursor: pointer;" title="刷新" data-pid="{$pid}" data-value="{$key}">&#xe669;</i>
                                            <span><i class="add"></i>区域</span>
                                            <span><i class="cz"></i>充值</span>
                                            <span><i class="tx"></i>提现</span>
                                            <span><i class="order"></i>订单</span>
                                        </li>
                                        <volist name="c" id="co">
                                            <li>
                                                <span>{$co['name']}</span>
                                                <span class="orange">￥{$statistic[$key]['recharge']}</span>
                                                <span class="orange">￥{$statistic[$key]['money']}</span>
                                                <span class="green">{$statistic[$key]['order']}</span>
                                            </li>
                                        </volist>
                                    </eq>
                                </ul>
                            </div>
                        </volist>
                    </div>
                </div>
            </div>
        </volist>
    </div>

</div>
<div class="index-right-cont">
    <div class="todo">
        <div class="tongji-title">
            <span></span>待办事项
        </div>
        <div class="layui-tab" style="margin-top: 20px">
            <ul class="dcl-title layui-tab-title">
                <li class="layui-this">
                    用户报警
                    <notempty name="alarm['count']">
                        <span class="layui-badge">{$alarm['count']}</span>
                    </notempty>
                </li>
                <li>
                    城际订单
                    <notempty name="inter_order['count']">
                        <span class="layui-badge">{$inter_order['count']}</span>
                    </notempty>
                </li>
            </ul>
            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">
                    <notempty name="alarm['data']">
                        <ul class="dcl-list">
                            <volist name="alarm['data']" id="ad">
                                <li>
                                    <a href="javascript:void(0)" data-url="{$url_alarm}?common_id={$ad['common_id']}"
                                       title="{$ad['content']}" onclick="openWeb(this)">{$key+1}-{$ad['content']|mb_truncate=0,100}</a>
                                </li>
                            </volist>
                        </ul>
                    </notempty>
                </div>
                <div class="layui-tab-item">
                    <notempty name="inter_order['data']">
                        <ul class="dcl-list">
                            <volist name="inter_order['data']" id="iod">
                                <li>
                                    <a href="javascript:void(0)" data-url="{$url_order}?common_id={$iod['common_id']}"
                                       title="{$iod['content']}" onclick="openWeb(this)">{$key+1}-{$iod['content']|mb_truncate=0,30}</a>
                                </li>
                            </volist>
                        </ul>
                    </notempty>
                </div>
            </div>
        </div>
    </div>
    <div class="date">
        <div class="jefixeitem" id="date"></div>
    </div>
</div>
<script src='{$protocol}cdn.bootcss.com/socket.io/2.0.3/socket.io.js'></script>
<script type="text/javascript">
    var layer;
    layui.use(['element','layer','laydate'], function () {
        var element = layui.element, laydate = layui.laydate,$ = layui.jquery;
        layer = layui.layer;
        laydate.render({
            elem: '#date' //或 elem: document.getElementById('test')、elem: lay('#test') 等
            ,position: 'static'
            ,min:0
        });
        element.on('collapse(region)', function(data){
            var title = data.title;
            if(title.data('act')=='no'){
                title.data('act','yes');
                ajax(title.data('pid'),title.data('value'),'collapse');
            }
        });
        var flag = "{$link}",index=0;
        if(flag){
            // 连接服务端
            var socket = io('{$url}');
            // 连接后登录
            socket.on('connect', function(){
                socket.emit('login', "{$admin_id}");
            });
            // 后端推送来消息时
            socket.on('new_msg', function(msg){
                var data = JSON.parse(msg);
                index++;
                switch (data['type']){
                    case 'order':
                        layer.open({
                            type: 1
                            ,title: data['title']
                            ,offset: 'rb' //具体配置参考：http://www.layui.com/doc/modules/layer.html#offset
                            ,id: 'layerDemorb'+index //防止重复弹出
                            ,content: '<div style="padding: 20px 50px 50px;">'+ data['content'] +'</div>'
                            ,area:'300px'
                            //,btn: '关闭全部'
                            // ,btnAlign: 'c' //按钮居中
                            ,shade: 0 //不显示遮罩
                            ,cancel: function(ind){
                                index--;
                                layer.close(ind);
                            }
                        });
                        break;
                    case 'alarm':
                        layer.open({
                            type: 1
                            ,title: [data['title'],'color:red']
                            ,offset: 'auto' //具体配置参考：http://www.layui.com/doc/modules/layer.html#offset
                            ,id: 'layerDemorb'+index //防止重复弹出
                            ,content:  '<div style="padding: 20px 50px 50px;color: red">'+ data['content'] +'</div>'
                            ,btn: '我知道了'
                            ,area:'300px'
                            // ,btnAlign: 'c' //按钮居中
                            ,shade: 0 //不显示遮罩
                            ,function(ind){
                                index--;
                                layer.close(ind);
                            }
                            ,cancel: function(ind){
                                index--;
                                layer.close(ind);
                            }
                        });
                        break;
                    case 'login':
                    case 'logout':
                        layer.msg(data['msg'],{time: 5000},function () {
                            index--;
                        });
                        break;
                    default:
                        index--;
                        break;
                }
            });
        }
    });
    function refresh(obj) {
        $(obj).addClass('layui-anim-rotate layui-anim-loop');
        ajax($(obj).data('pid'),$(obj).data('value'),$(obj))
    }
    function ajax(pid, cid, act) {
        var str = "<i class='layui-icon layui-anim layui-anim-rotate layui-anim-loop' style='font-size: 40px;'>&#xe63d;</i>";
        var ul = $('#sta_' + pid + '_' + cid);
        $.ajax({
            type: 'POST',
            url: '{$url_sta}',
            data: {pid: pid, cid: cid},
            beforeSend:function(){
                if(act == 'collapse'){
                    ul.css({'text-align':'center'}).html(str);
                }
            },
            success: function (res) {
                if(act == 'collapse'){
                    ul.html('');
                }else{
                    act.removeClass('layui-anim-rotate layui-anim-loop');
                }
                switch (res['status']) {
                    case 1:
                        ul.html(res['html']);
                        break;
                    default:
                        layer.alert(res['msg'], {icon: 2});
                }
            },
            dataType: 'json'
        });
    }
    function openWeb(obj) {
        layer.open({
            type: 2,
            title: '详情',
            shadeClose: true,
            shade: 0.8,
            area: ['80%', '80%'],
            content: $(obj).data('url')
        });
    }
</script>
</body>
</html>








